// Author: Ivan Chau
package uk.ac.cam.kcic2.scene;

import uk.ac.cam.kcic2.math.Vector3D;


public class Colour extends Vector3D{
	
	public Colour(double[] rgb) {
		super(rgb);
	}
	
	public Colour(double r, double g, double b){
		super(r, g, b);
	}
	
	public Colour(int RGB){
		super((RGB>>Byte.SIZE*2)&255, (RGB>>Byte.SIZE)&255, RGB & 255);
	}
	
	public int toRGB(){	// compute the int in the format of Java Color
		int RGB = -1;
		int red = (int) x > 255? 255 : (int) x;
		int green = (int) y > 255? 255 : (int) y;
		int blue = (int) z > 255? 255 : (int) z;
		
		RGB = RGB << Byte.SIZE | red & 255;
		RGB = RGB << Byte.SIZE | green & 255;
		RGB = RGB << Byte.SIZE | blue & 255;
		return RGB;
	}
	
}
